<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>银行卡修改</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>

<body>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <form action="" method="post" class="form form-horizontal" id="form-admin-role-add">

            <div class="form-group">
                <label class="col-sm-3 control-label">持卡人姓名：</label>
                <div class="col-sm-6">
                    <input id="user_name" name="user_name" value="{$data.user_name}"  class="form-control" type="text" maxlength="4" datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开户银行：</label>
                <div class="col-sm-6">
                    <select class="form-control" name="bank_name" id="bank_name">
                        <option value="">请选择</option>
                        <foreach name="bank_list" item="bank">
                            <option value="{$bank.name}" <if condition="$data['bank_name'] eq $bank['name']">selected="selected"</if>>{$bank.name}</option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">银行卡卡号：</label>
                <div class="col-sm-6">
                    <input id="bank_number" name="bank_number" value="{$data.bank_number}" maxlength="30"  class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">支行名称：</label>
                <div class="col-sm-6">
                    <input id="bank_branch" name="bank_branch" value="{$data.bank_branch}" class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">所在地：</label>
                <div class="col-sm-3">
                    <select class="form-control" style="height: 32px;" name="adds" id="adds">
                        <option value="">请选择</option>
                        <foreach name="adds" item="a">
                            <option value="{$a.name}" <if condition="$data['bank_adds'] eq $a['name']">selected="selected"</if> >{$a.name}</option>
                        </foreach>
                    </select>
                </div>
                <div class="col-sm-3">
                    <select class="form-control" style="height: 32px;" name="city" id="city">
                        <option value="{$data.bank_city}">{$data.bank_city}</option>
                    </select>
                </div>

                <div class="col-sm-4 ng-scope">
                    <label class="help-block m-b-none" id="adds_alert" style="color: red;"></label>
                </div>
            </div>



            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button type="button" class="btn btn-success radius"  onclick="Bank_AddData()" id="admin-role-save" name="admin-role-save">
                        <i class="icon-ok"></i> 确定
                    </button>

                    <a style="margin-left: 20px;"onclick="layer_close();" class="btn btn-success btn-warning">
                        <i class="icon-ok"></i> 返回
                    </a>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->

<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>

<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script>
    $("#adds").change(function () {
        var adds = $("#adds").val();
        if(adds){
            $.post('__MODULE__/Capital/region',{name:adds},function (data) {
                if(data.status==1){
                    var city ='';
                    for(var i=0;i<data.msg.length;i++){
                        city +=  '<option value='+data.msg[i].name+'>'+data.msg[i].name+'</option>';
                    }
                    $("#city").html(city);$("#adds_alert").html("");submit6=true;
                }
            })
        }else{
            $("#city").html("<option value=''>请选择</option>");
            $("#adds_alert").html("不可为空");
        }
    });


    function Bank_AddData() {
        var user_name   = $("#user_name").val();
        var bank_name   = $("#bank_name").val();
        var bank_number = $("#bank_number").val();
        var bank_branch = $("#bank_branch").val();
        var adds = $("#adds").val();
        var city = $("#city").val();

        if(user_name=='') {
            $("#user_name").css("border-color", "#e51f44");
        }else if(bank_name=='') {
            $("#bank_name").css("border-color", "#e51f44");
        }else if(bank_number=='') {
            $("#bank_number").css("border-color", "#e51f44");
        }else if(bank_branch==''){
            $("#bank_branch").css("border-color", "#e51f44");
        }else if(adds==''){
            $("#adds").css("border-color", "#e51f44");
        } else {
            var index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            $.ajax({
                type:"POST",
                url:"__MODULE__/Capital/bank_saveData/id/{$data.id}",
                dataType:'json',
                data:{user_name:user_name,bank_name:bank_name,bank_number:bank_number,bank_branch:bank_branch,bank_adds:adds,bank_city:city},
                success:function(data){
                    layer.close(index);
                    if(data.status==1){
                        layer.msg(data.msg);
                        setTimeout(function () {location.reload();}, 1000);
                    }else if(data.status==0){
                        layer.msg(data.error);
                    }else{
                        layer.msg('网络错误',{icon: 2, time: 2000});
                    }
                },error:function(err){
                    //console.log(err);
                    layer.close(index);
                    layer.msg('error:网络错误',{icon: 2, time: 2000});
                }
            });
        }
    }
</script>
</body>
</html>
